﻿<!--#include file="const.asp"-->
<%
'====================================================================
' 感谢使用晴天3G智能建站系统..
' 作者:梁永强.QQ:766750857
' 官方网址:wap.qt3g.com
' 声明:软件版权归作者所有,没有经过作者本人同意不得非法破解和传播本程序
'====================================================================
%>


<%
if sid="Null" then
	Response.Redirect "login.asp"
	Response.end
end if
IF  Request.QueryString("Action")="login" Then
	call login
else
	call index
end if
end Function



Function index
	dim rs,sql,Runtxt,id
	Runtxt=qingtian.RunStr
    		id = Request("id")    
    		If id = "" Then id = 1
   		If Not IsNumeric(id) Then id = 1
    		id = CLng(id)
    		If id < 1 Then id = 1

%>
	<card title="编辑软件分类"><p align="left">
<%
		set rs=Server.CreateObject("ADODB.Recordset")
		Sql = "select top 1 *  FROM qingtian_phonefen where id="&id&""
		rs.open sql,conn,1,1
		if not (rs.eof and rs.bof) then
%>
   	栏目分类
	<%
	  set rs2=server.CreateObject("adodb.recordset")
	  sql2="select name from qingtian_phonefenn where id="&rs("listid")&" order by id asc"
	  rs2.open sql2,conn,1,1
	  if not (rs2.bof and rs2.eof) then
		%>
		<select name="listid<%=Runtxt%>" value="<%=rs("listid")%>">
                <option value="<%=rs("listid")%>"><%=qingtian.utf8(rs2("name"))%></option>
<%
          else
%>
		<select name="listid<%=Runtxt%>" value="0">
		<%
	  end if
	  Rs2.close
	  sql2="select id,name from qingtian_phonefenn where id<>"&rs("listid")&" order by id asc"
	  rs2.open sql2,conn,1,1
	  if not (rs2.bof and rs2.eof) then
	  For i=1 to rs2.RecordCount
		%>
		<option value="<%=rs2("id")%>"><%=qingtian.utf8(rs2("name"))%></option>
		<%
	  Rs2.MoveNext
	  Next
	  end if
	  Rs2.close
	  set rs2=nothing
	%>
	</select><br/>
	软件分类名称：<br/>
	<input emptyok="true"  name="name<%=Runtxt%>" maxlength="50" value="<%=qingtian.FormatEdit(rs("name"))%>" type="text"/><br/>
	<anchor>确定提交
    	<go href="editphonefen.asp?Action=login&amp;id=<%=id%>&amp;sid=<%=sid%>" method='post'>
        <postfield name="name" value="$(name<%=Runtxt%>)"/>
        <postfield name="listid" value="$(listid<%=Runtxt%>)"/>
    	</go>
	</anchor><br/>
<%
		end if
		rs.Close
		Set rs = Nothing
%>

-------------<br/>
<a href='phonefen.asp?sid=<%=sid%>'>返回软件分类管理</a><br/>
<a href='index.asp?sid=<%=sid%>'>后台管理首页</a><br/>
<%
End Function


Function login

		dim name,rs,sql,errs,id
		name=Request.form("name")
    		id = Request("id")    
    		If id = "" Then id = 1
   		If Not IsNumeric(id) Then id = 1
    		id = CLng(id)
    		If id < 1 Then id = 1
    		listid = Request.form("listid")
    		If listid = "" Then listid = 1
   		If Not IsNumeric(listid) Then listid = 1
    		listid = CLng(listid)
    		If listid < 1 Then listid = 1
		errs=""
		if name="" then errs=errs & "软件分类标题不能为空<br/>"
	%>
	<card id="login" title="编辑软件分类" ontimer="phonefen.asp?sid=<%=sid%>"><timer value="20"/>
		<p align="left">
	<%
	IF len(errs)=0 then


		set rs=Server.CreateObject("ADODB.Recordset")
		Sql = "select top 1 *  FROM qingtian_phonefen where id="&id&""
		rs.open sql,conn,1,3
		if not (rs.eof and rs.bof) then
			rs("name")=name
			rs("listid")=listid
		rs.update()
		end if
		rs.Close
		Set rs = Nothing
		%>编辑软件分类成功!<br/><%

	else%>
		<%=errs%>
		<a href="editphonefen.asp?id=<%=id%>&amp;sid=<%=sid%>">返回修改</a><br/>
<%	end if
%>
<a href='phonefen.asp?sid=<%=sid%>'>返回软件分类管理</a><br/>
<a href='index.asp?sid=<%=sid%>'>后台管理首页</a><br/>
<%
end Function 


%>
